<body>
<div class="x-body">
	<form class="layui-form">
		<div class="layui-form-item">
			<label for="username" class="layui-form-label">
				<span class="x-red">*</span>登录名
			</label>
			<div class="layui-input-inline">
				<input type="text" id="username" name="nickname" required="" lay-verify="required"
					   autocomplete="off" value="{$admin.nickname}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">
				<span class="x-red">*</span>将会成为您唯一的登入名
			</div>
		</div>
		<div class="layui-form-item">
			<label for="phone" class="layui-form-label">
				<span class="x-red">*</span>手机
			</label>
			<div class="layui-input-inline">
				<input type="text" value="{$admin.phone}" id="phone" name="phone" required="" lay-verify="phone"
					   autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">
				<span class="x-red">*</span>将会成为您唯一的登入名
			</div>
		</div>
		<div class="layui-form-item">
			<label for="L_email" class="layui-form-label">
				<span class="x-red">*</span>邮箱
			</label>
			<div class="layui-input-inline">
				<input type="text" value="{$admin.email}" id="L_email" name="email" required="" lay-verify="email"
					   autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">
				<span class="x-red">*</span>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span class="x-red">*</span>角色</label>
			<div class="layui-input-block">
				{volist name='role' id='row'}
				<input type="checkbox" name="role_id[{$row.role_id}]" lay-skin="primary" title="{$row.role_name}" {in name="$row.role_id" value="$role_id" } checked
					   {/in}>
				{/volist}
			</div>
		</div>
		<div class="layui-form-item">
			<label for="L_pass" class="layui-form-label">
				<span class="x-red">*</span>密码
			</label>
			<div class="layui-input-inline">
				<input type="password" id="L_pass" name="password" required="" lay-verify="pass"
					   autocomplete="off" class="layui-input" >
			</div>
			<div class="layui-form-mid layui-word-aux">
				6到16个字符
			</div>
		</div>
		<div class="layui-form-item">
			<label for="L_repass" class="layui-form-label">
				<span class="x-red">*</span>确认密码
			</label>
			<div class="layui-input-inline">
				<input type="password" id="L_repass" name="repassword" required="" lay-verify="repass"
					   autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label for="L_repass" class="layui-form-label">
			</label>
			<button class="layui-btn" admin_id="{:input('admin_id')}" lay-filter="add" lay-submit="">
				增加
			</button>
		</div>
	</form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form
            , layer = layui.layer;

        //监听提交
        form.on('submit(add)', function (data) {
            data.field.admin_id = $(this).attr('admin_id');
            $.post("{:url('admin/Admins/editAdmin')}", data.field, function (res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.msg(res.msg,{icon: 1},function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                    })
                }
            });
            return false;
        });


    });
</script>
</body>
